#include <iostream>
#include <unistd.h>
#include <ctime>
#include "ThreadPool.hpp"
#include "Task.hpp"
using namespace std;

int main()
{
    ThreadPool<Task> *tp = new ThreadPool<Task>(5);
    tp->Start();
    srand(time(nullptr) ^ getpid());
    while(true)
    {
        // 1. 构建任务
        int x = rand() % 10 + 1;
        int y = rand() % 9;
        usleep(100);
        char op = opers[rand() % opers.size()];

        Task t(x, y, op);
        tp->Push(t);
        // 2. 交给线程去处理
        cout << "main thread make task: " << t.GetTask() << endl;
        sleep(1);
    }   
    return 0;
}